<?php

/**
 * Beca form base class.
 *
 * @method Beca getObject() Returns the current form's model object
 *
 * @package    auip
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseBecaForm extends BaseFormDoctrine
{
  public function setup()
  {
     $this->setWidgets(array(
      'id'                    => new sfWidgetFormInputHidden(),
      'logo'                  => new sfWidgetFormInputFile(),
      'nombre'                => new sfWidgetFormTextarea(),
      'descripcion'           => new sfWidgetFormTextarea(),
      'dirigido_a'            => new sfWidgetFormInputText(),
      'requisitos'            => new sfWidgetFormTextarea(),
      'plazo'                 => new sfWidgetFormInputText(),
      'fecha_inicio'          => new sfWidgetFormInputText(),
      'fecha_fin'             => new sfWidgetFormInputText(),      
      'tipo_beca'=> new sfWidgetFormDoctrineDependentSelect(array('model' => $this->getRelatedModelName('TipoBeca'))),
      //'pais_id' => new sfWidgetFormDoctrineDependentSelect(array('model' => 'Pais')),
      'pais_id' => new sfWidgetFormDoctrineDependentSelect(array('model' => 'Pais')),
      'region_id'=> new sfWidgetFormDoctrineDependentSelect( array('model' => 'Region')),      
      'universidad_ofrece_id' => new sfWidgetFormDoctrineDependentSelect(array('model' => 'Universidad')),
    ));

        $this->setValidators(array(
      'id'                    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false), array('required' => 'Please select a sheet type to export.')),      
      'logo'                  => new sfValidatorFile(array('required'=> false, 'path'=> sfConfig::get('sf_upload_dir').'/logos', 'namefile'=>'logo', 'mime_categories'=>'web_images')),
      'nombre'                => new sfValidatorString(array('required' => true)),
      'descripcion'           => new sfValidatorString(array('required' => false)),
      'dirigido_a'            => new sfValidatorString(array('required' => false)),
      'requisitos'            => new sfValidatorString(array('required' => false)),
      'plazo'                 => new sfValidatorString(array('required' => false)),
      'fecha_inicio'          => new sfValidatorDate(),
      'fecha_fin'             => new sfValidatorDate(),  
      
      'tipo_beca' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TipoBeca'), 'required' => false)),
      'pais_id' => new sfValidatorDoctrineChoice(array('model' => 'Pais', 'required' => false)),
      'region_id' => new sfValidatorDoctrineChoice(array('model' => 'Region', 'required' => false)),      
      'universidad_ofrece_id' => new sfValidatorDoctrineChoice(array('model' => 'Universidad', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('beca[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Beca';
  }

}
